interface NameInfo {
	firstName: string,
	lastName: string,
}
const getFullName = ({ firstName, lastName }: NameInfo): string => {
	return `${firstName}-->>${lastName}`
}
console.log(getFullName({ firstName: "橘子", lastName: "橙子" }))

//加个问号 ? 表示可选;	readonly只读属性
interface Vegetables {
	color: string,
	type?: string,
	// [type: string]: any
	readonly size: number
}
const getVegetables = ({ color, type, size }: Vegetables): string => {
	return `${color}--${type}--${size}`
}
console.log(getVegetables({ color: "红色", size: 10 }))

// interface 接口除了可以定义对象的结构 还可以定义函数的结构

interface myFunc {
	(num1: number, num2: number): number
}
const myFunction: meFunc = (num1, num2) => {
	return (num1 + num2)
}
console.log(myFunction(1, 3))

type meFunc = (num1: number, num2: number) => number
const meFunction: meFunc = (num1, num2) => {
	return (num1 + num2)
}
console.log(myFunction(2, 3))

// 接口匹配
interface RoleDic {
	[id: number]: string
}
const RoleDicObj: RoleDic = {
	6789: "橘子",
	7980: "橙子"
}

// 接口继承
interface Dome1 {
	color: string
}
interface Dome2 extends Dome1 {
	age: number
}
interface Dome3 extends Dome2 {
	seiz: string
}

const d1: Dome1 = {
	color: "红色"
}
const d2: Dome2 = {
	color: "绿色",
	age: 18
}
const d3: Dome3 = {
	color: "蓝色",
	age: 24,
	seiz: "怎么回事"
}

interface Counter {
	(): void,
	count: number
}

// const getCounter: Counter = () => {
// 	const c = () => { c.count++ }
// 	c.count = 0
// 	return c
// }

// const counter: Counter = getCounter()
// counter()